﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using SPAdvancedSearch.Editors;

namespace SPAdvancedSearch.Inputs
{

    /// <summary>
    /// Defines a value control for displaying a TextBox input.
    /// </summary>
    public class TextBoxValueControl : ValueControlBase
    {

        #region Fields

        private TextBoxEx _textBox;

        #endregion

        #region Ctor

        /// <summary>
        /// Creates an instance of <see cref="TextBoxValueControl"/>.
        /// </summary>
        /// <param name="managedPropertyName"></param>
        public TextBoxValueControl(string managedPropertyName)
            : base(managedPropertyName)
        {
        }

        #endregion

        #region Methods

        /// <summary>
        /// Overridden to return a <see cref="TextBox"/>.
        /// </summary>
        /// <returns></returns>
        public override ISearchPropertyInputControl GetDisplayControl()
        {
            if (_textBox == null)
                _textBox = new TextBoxEx();

            return _textBox;
        }

        /// <summary>
        /// Overridden to return a null value since an Editor Control is not required.
        /// </summary>
        /// <returns></returns>
        public override EditorControlBase GetEditorControl()
        {
            return null;
        }

        #endregion

    }
}
